﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Pixysoft.Framework.Verifications
{
    /// <summary>
    /// 多参数验证 只要有一个不符合 就全部否定
    /// </summary>
    class MultipleTrueVerifior : IVerifior
    {
        object[] targets = null;

        string message = null;

        private MultipleTrueVerifior()
        {
        }

        internal MultipleTrueVerifior(params object[] values)
        {
            targets = values;

            if (targets == null)
                targets = new object[] { };
        }



        public IVerifior IsNullOrEmpty()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsNullOrEmpty().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsNotNullOrEmpty()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsNotNullOrEmpty().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }




        public IVerifior IsInt()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsInt().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsDouble()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsDouble().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsDateTime()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsDateTime().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsShort()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsShort().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLong()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLong().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsDecimal()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsDecimal().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsFloat()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsFloat().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }




        public IVerifior IsGreater(int value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreater(double value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreater(DateTime value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreater(short value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreater(long value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreater(decimal value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreater(float value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreater<T>(T value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreater<T>(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }




        public IVerifior IsLess(int value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLess(double value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLess(DateTime value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLess(short value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLess(long value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLess(decimal value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLess(float value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLess<T>(T value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLess<T>(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }



        public IVerifior IsGreaterEqual(int value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreaterEqual(double value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreaterEqual(DateTime value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreaterEqual(short value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreaterEqual(long value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreaterEqual(decimal value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreaterEqual(float value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsGreaterEqual<T>(T value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsGreaterEqual<T>(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }



        public IVerifior IsLessEqual(int value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLessEqual(double value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLessEqual(DateTime value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLessEqual(short value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLessEqual(long value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLessEqual(decimal value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLessEqual(float value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLessEqual<T>(T value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLessEqual<T>(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }


        public IVerifior IsEqual(object value)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsEqual(value).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsEqual(object value, bool ignoreCase)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsEqual(value, ignoreCase).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }



        public IVerifior IsChinese()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsChinese().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsEmail()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsEmail().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsUrl()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsUrl().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsIP()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsIP().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsTel()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsTel().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsMobile()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsMobile().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsPostCode()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsPostCode().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsQQ()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsQQ().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsIDCard()
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsIDCard().Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsInLengthRange(int min, int max)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsInLengthRange(min, max).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }

        public IVerifior IsLength(int length)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsLength(length).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }


        public IVerifior IsMatchRegex(string regex)
        {
            foreach (object target in targets)
            {
                if (new TrueVerifior(target).IsMatchRegex(regex).Result(out message))
                    continue;

                return new FalseVerifior(message);
            }

            return this;
        }



        public bool Result()
        {
            return true;
        }

        bool IVerifior.Result(out string message)
        {
            message = this.message;

            return true;
        }
    }
}
